package com.qys.livesMall.system.controller.sys;

import com.qys.livesMall.common.result.R;
import com.qys.livesMall.framework.view.QysPage;
import com.qys.livesMall.system.model.dto.words.DeleteBatch;
import com.qys.livesMall.system.model.dto.words.EditWords;
import com.qys.livesMall.system.model.dto.words.WordsSearch;
import com.qys.livesMall.system.model.vo.sys.WordsVO;
import com.qys.livesMall.system.service.SysSensitiveVocabularyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * 敏感词库
 *
 * @author
 * @since 2023-06-08
 */
@RestController
@RequestMapping("/web/sv/")
public class SysSensitiveVocabularyController {

    @Autowired
    private SysSensitiveVocabularyService sensitiveVocabularyService;

    /**
     * 列表
     * @param search
     * @return
     */
    @PostMapping("list")
    public R<QysPage<WordsVO>> list(@RequestBody WordsSearch search){
        return R.ok(sensitiveVocabularyService.list(search));
    }

    /**
     * 新增
     * @param editWords
     * @return
     */
    @PostMapping("add")
    public R add(@RequestBody EditWords editWords){
        return sensitiveVocabularyService.add(editWords);
    }

    /**
     * 编辑
     * @param editWords
     * @return
     */
    @PostMapping("edit")
    public R edit(@RequestBody EditWords editWords){
        return sensitiveVocabularyService.edit(editWords);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("{id}")
    public R del(@PathVariable Long id){
        return sensitiveVocabularyService.del(Arrays.asList(id));
    }

    /**
     * 删除-批量
     * @param deleteBatch
     * @return
     */
    @DeleteMapping("/batch")
    public R delBatch(@RequestBody DeleteBatch deleteBatch){
        return sensitiveVocabularyService.del(deleteBatch.getIds());
    }

}
